package top.vanchor.flexible.controller.publics;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.*;
import top.vanchor.flexible.common.Res;
import top.vanchor.flexible.entity.Album;
import top.vanchor.flexible.entity.Artist;
import top.vanchor.flexible.entity.Category;
import top.vanchor.flexible.entity.Special;
import top.vanchor.flexible.service.IAlbumService;
import top.vanchor.flexible.service.IArtistService;
import top.vanchor.flexible.service.ICategoryService;
import top.vanchor.flexible.service.ISpecialService;

import javax.annotation.Resource;
import java.util.List;

@Log4j2
@Api("公共接口-需口令")
@RestController
@RequestMapping("/publicApiAuth")
public class publicApiAuthController {

    @Resource
    private ISpecialService specialService;

    @Resource
    private IArtistService artistService;

    @Resource
    private IAlbumService albumService;

    @Resource
    private ICategoryService categoryService;


    @ApiOperation("查询专题列表")
    @ResponseBody
    @GetMapping("/getSpecialList")
    public Res<List<Special>> getSpecialList(@RequestParam(name = "type",required = false) Integer type) {
        return Res.success(specialService.list(new QueryWrapper<Special>(){{
            if (type != null) {
                eq("type", type);
            }
        }}));
    }

    @ApiOperation("查询艺术家列表")
    @ResponseBody
    @GetMapping("/getArtistList")
    public Res<List<Artist>> getArtistList() {
        return Res.success(artistService.list());
    }

    @ApiOperation("查询专辑列表")
    @ResponseBody
    @GetMapping("/getAlbumList")
    public Res<List<Album>> getAlbumList() {
        return Res.success(albumService.list());
    }

    @ApiOperation("查询扩展资料类目列表")
    @ResponseBody
    @GetMapping("/getCategoryList")
    public Res<List<Category>> getCategoryList() {
        return Res.success(categoryService.list());
    }

}
